import {BrowserRouter, Switch, Route, Redirect} from 'react-router-dom';
import 'antd/dist/antd.css'; // or 'antd/dist/antd.less'
import MyLogin from './router/MyLogin/MyLogin';
import Main from './router/Main/Main';
import Admin from './router/Admin/index';
import RegistrationForm from './router/Register/index'

const vaildatorAdmin = ()=>{
  if(/admin/.test(document.cookie)){
    return <Admin />
  }
}


function App() {
  return (
    <BrowserRouter>
      <Switch>
        <Route path={"/login"} render={()=><MyLogin/> }></Route>
        <Route path={'/app'} render={()=><Main />} ></Route>
        <Route path={'/admin'} render={vaildatorAdmin} />
        <Route path={'/register'} render={()=><RegistrationForm />} />
        <Redirect to="/login" ></Redirect>
      </Switch>
    </BrowserRouter>
  );
}

export default App;
